import Vue from 'vue';
import Vuex from 'vuex';
// vuex持久化缓存
import createPersistedState from 'vuex-persistedstate';

/**
 * import model vuex js
 */
import app from './modules/app';
import user from './modules/user';
import dashboard from './modules/dashboard';
import attr from './modules/attr';
import brand from './modules/brand';
import shop from './modules/shop';
import product from './modules/product';
import userfocus from './modules/userfocus';

Vue.use(Vuex);

export default new Vuex.Store({
  plugins: [
    createPersistedState({
      key: 'qbmfbrand',
      paths: ['app', 'user', 'userfocus', 'dashboard', 'shop', 'product']
    })
  ],
  actions: {
    clearAll({ commit }) {
      commit('user/reset');
      commit('userfocus/reset');
      commit('app/reset');
      commit('dashboard/reset');
      commit('attr/reset');
      commit('brand/reset');
      commit('shop/reset');
      commit('product/reset');
    }
  },
  modules: {
    user,
    userfocus,
    app,
    dashboard,
    attr,
    brand,
    shop,
    product
  }
});
